<template>
  <div>
    <el-form ref="form" :model="form" label-width="100px">
      <el-form-item label="教师账号">
        <el-input v-model="form.teacherAccount"></el-input>
      </el-form-item>

      <el-form-item label="密码">
        <el-input v-model="form.teacherPass"></el-input>
      </el-form-item>

      <el-form-item label="教师姓名">
        <el-input v-model="form.teacherName"></el-input>
      </el-form-item>

      <el-form-item label="教师年龄">
        <el-input v-model="form.teacherAge"></el-input>
      </el-form-item>

      <el-form-item label="性别">
        <el-select v-model="form.teacherSex" placeholder="请选择教师性别">
          <el-option label="男" value="男"></el-option>
          <el-option label="女" value="女"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="教师职称">
        <el-input v-model="form.teacherTitle"></el-input>
      </el-form-item>

      <el-form-item label="身份证号">
        <el-input v-model="form.teacherIdentify"></el-input>
      </el-form-item>

      <el-form-item label="教师简介">
        <el-input v-model="form.teacherDisc" type="textarea"></el-input>
      </el-form-item>


      <el-form-item>
        <el-button type="primary" @click="onSubmit(form)">立即添加</el-button>
        <el-button @click="handleOnCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data () {
    return {
      form: {
        teacherAccount: null,
        teacherAge: null,
        teacherDisc: null,
        teacherIdentify: null,
        teacherName: null,
        teacherPass: null,
        teacherSex: null,
        teacherTitle: null,
      },
      fileList: [],
      realFileUrl: [],
    };
  },
  methods: {

    // 立即发布
    async onSubmit (form) {
      //  valid
      // console.log(form)
      for (let each in form) if (!form[each]) return this.$message.warning("请填写完整");
      const res = await this.$http.teacherRegister(form);
      if (res.code !== 0) return this.$alert("出错啦");
      return this.$router.go(0);
    },
    handleOnCancel (e) {
      this.$emit("cancel");
    },

  },
};
</script>

<style lang="less" scoped>
.el-form {
  margin-top: 20px;
}
</style>
